package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gears_software.sxdc.dccx.data.model.NoticeModel;
import com.gears_software.sxdc.dccx.ui.view.MessageCenterItemView;
import com.gears_software.sxdc.dccx.ui.view.MessageCenterItemView_;

import java.util.List;

/**
 * Created by chezhenzhen on 2017/10/17.
 */

public class MessageCenterAdapter extends BaseAdapter {
    Context context;
    List<NoticeModel> list;

    public MessageCenterAdapter(Context context, List<NoticeModel> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public NoticeModel getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MessageCenterItemView itemView;
        if (convertView == null) {
            itemView = MessageCenterItemView_.build(context);
        } else {
            itemView = (MessageCenterItemView) convertView;
        }
        itemView.bind(list.get(position));
        return itemView;
    }
}
